#ifndef _TREE_H
#define _TREE_H

#include "../Globals/_cdslib_globals.h"
#include "../Node/_Node.h"

/* Tree structure */
typedef struct {
    size_t length;
    int (*compare)(const void *objectOne, const void *objectTwo);
    _Node *root;
} Tree;

/* Function prototypes */
void  initTree  (Tree *initThis,
                 int (*compareObject)(const void *objectOne,
                                      const void *objectTwo));
Array deleteTree(Tree *deleteThis);

int   TreeAdd     (Tree *t, void  *addThis);
int   TreeContains(Tree *t, void  *findThis);
void *TreeExtract (Tree *t, void  *extractThis);

size_t  __height     (_Node *root);
_Node  *__bottomRight(_Node *root);
_Node  *__bottomLeft (_Node *root);
_Node **__TreeNodeGet(Tree *t, void *getThis);

#endif
